package com.oct.ywsc.job.schedule;

import com.oct.ywsc.job.TransTaskScheduler;

import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;


/**
 * 自定义拒绝策略
 */
public class CustomerRejectedExecutionHandler implements RejectedExecutionHandler {
    @Override
    public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
        // 消息队列拒绝，则标记暂停接收kafka消息
        TransTaskScheduler.canAcceptable =false;

        // 并开启一个线程执行当前任务
        r.run();
    }
}
